import 'dart:io';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';

/// my widget
import 'package:suburban_inside_flutter/screen.dart';
import 'package:suburban_inside_flutter/chat_box.dart';
import 'package:suburban_inside_flutter/widget/Pannable.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();

  // WindowOptions windowOptions = const WindowOptions(
  //   size: Size(1000, 600), // 设置窗口初始大小
  //   maximumSize: Size(1000, 600),
  //   minimumSize: Size(1000, 600),
  //   center: true,
  //   title: '布局可视化',
  // );
  // windowManager.waitUntilReadyToShow(windowOptions, () async {
  //   await windowManager.show();
  //   await windowManager.focus();
  // });
  runApp(const MyApp());

  /// Configure here: bitsdojo_window
  doWhenWindowReady(() {
    final win = appWindow;
    const initialSize = Size(1000, 600); // Size(900, 576);
    win.minSize = initialSize; // Size(1200, 768);
    win.maxSize = initialSize;
    win.size = initialSize;
    win.alignment = Alignment.center;
    win.title = "Suburban-env Debugger";

    win.show();
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '布局可视化',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      debugShowCheckedModeBanner: false,
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(
        child: Padding(
          padding: EdgeInsets.all(26),
          child: Pannable(
            minValue: 300,
              child1Value: 600,
              child1: Screen(),
              child2: ChatBox(),
          )
        )
      ),
      backgroundColor: Color.fromARGB(255, 41, 41, 41),
    );
  }
}




